package hiho.ku._1037;

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int[] f = new int[n + 1];
		int[] g = new int[n + 1];
		for (int i = 1; i <= n; i++) {
			for (int j = 1; j <= i; j++)
				g[j] = in.nextInt();
			for (int j = i; j >= 1; j--)
				f[j] = Math.max(f[j], f[j - 1]) + g[j];
		}
		int ans = 0;
		for (int i = 1; i <= n; i++)
			ans = Math.max(ans, f[i]);
		System.out.println(ans);
	}

}
